<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>this练习</title>
</head>
<body>
    <script>
        var name = 'window'
        var obj1 = {
            name: '1',
            fn1: function() {
                console.log(this.name);
            },
            fn2: () => console.log(this.name),
            fn3: function () {
                return function () {
                    console.log(this.name);
                }
            },
            fn4: function () {
                return () => console.log(this.name);
            }
        }

        var obj2 = {
            name: '2'
        }

        obj1.fn1();                             
        obj1.fn1.call(obj2);                    

        obj1.fn2();                             
        obj1.fn2.call(obj2);                    

        obj1.fn3()();                           
        obj1.fn3().call(obj2);                  
        obj1.fn3.call(obj2)();                  

        obj1.fn4()();                           
        obj1.fn4().call(obj2);                  
        obj1.fn4.call(obj2)();                  
    </script>
</body>
</html>